s = input()
sk = ""
flag = True
for skobka in s:
    if skobka in "({[<":
        sk = sk + skobka
    elif skobka in ")}]>":
        if sk == "":
            flag = False
        else:
            l = sk[-1]
            if skobka == ")" and l == "(":
                sk = sk[:-1]
            elif skobka == "]" and l == "[":
                sk = sk[:-1]
            elif skobka == "}" and l == "{":
                sk = sk[:-1]
            elif skobka == ">" and l == "<":
                sk = sk[:-1]
if flag == False:
    print(False)
elif sk == "":
    print(True)
else:
    print(False)